package com.always.electrical.energy.web.res;

import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;

@Data
@Accessors(chain = true)
public class WebBaseResponse implements Serializable {

    /**
     * 错误代码,200是正常,其他是错误
     */
    private Integer code;

    /**
     * 错误消息
     */
    private String msg;

    /**
     * 数据结果
     */
    private WebResponse data;

    public static WebBaseResponse success(WebResponse data) {
        return new WebBaseResponse().setCode(200).setMsg("").setData(data);
    }

    public static WebBaseResponse errorDeviceIds() {
        return new WebBaseResponse().setCode(500).setMsg("设备ID不能为空");
    }

    public static WebBaseResponse errorConnectMqtt() {
        return new WebBaseResponse().setCode(500).setMsg("mqtt回复超时");
    }
}
